import java.util.HashSet;
import java.util.Scanner;

/**
 * The type Tester.
 */
public class Tester {
    /**
     * The L.
     */
    public Lottery l;
    /**
     * The User lottery.
     */
    public MySet userLottery;

    /**
     * The entry point of application.
     *
     * @param args the input arguments
     */
    public static void main(String[] args) {
        Tester t = new Tester();
        t.initialise();
        t.process();
    }

    /**
     * Initialise.
     */
    public void initialise() {
        l = new Lottery();
        userLottery = new MySet();
//        userLottery.add(1);
//        userLottery.add(2);
//        userLottery.add(3);
//        userLottery.add(4);
//        userLottery.add(5);
//        userLottery.add(6);

    }

    /**
     * Process.
     */
    public void process() {
        Scanner sc = new Scanner(System.in);
        String selection = "";
        boolean exit = false;
        do {
            showMenu();
            selection = sc.nextLine();

            switch (selection) {
                case "1":
                    showLotteryInstructions();
                    break;
                case "2":
                    l.useLotterySystem();
                    break;
                case "3":
                    testAll();
                    break;
                case "0":
                    System.out.println("Thanks for using! Goodbye~\n");
                    exit=true;
                    break;
                default:
                    System.out.println("That is not a valid choice, please try again");
                    break;
            }
        }while (!exit);
    }

    /**
     * Show menu.
     */
    public void showMenu(){
        System.out.println("===================  M  e  n  u  ===================");
        System.out.println("How to use Lottery system                     <--1");
        System.out.println("Lottery system                                <--2");
        System.out.println("Show tester's result                          <--3");
        System.out.println("Exit the System                               <--0");
        System.out.println("====================================================");
        System.out.println("--> Select options by entering a number <--");
    }

    /**
     * Show lottery instructions.
     */
    public void showLotteryInstructions(){
        System.out.println("=============== Lottery System Instructions ===============");
        System.out.println("1. Set the number of players");
        System.out.println("2. Set the maximum number for the lottery (10-100)");
        System.out.println("3. Set how many weeks you want to buy with the same lottery numbers");
        System.out.println("   *each week you will buy SAME lottery number*");
        System.out.println("4. Each player will select SIX non-repeating lottery numbers");
        System.out.println("   Please entering them separated by spaces(order does not matter)");
        System.out.println("   Example of a valid selection:");
        System.out.println("   5 12 19 20 27 35  (This will select the numbers 5, 12, 19, 20, 27, and 35)");
        System.out.println("5. The system will randomly generate winning numbers each week.");
        System.out.println("6. More numbers matching the winning numbers means more prizes!");
        System.out.println("7. The system will display the winning number and your winnings");
        System.out.println("8. Good luck!");
    }

    /**
     * Test all.
     */
    public void testAll(){
        MySetTester();
        LotteryTester();
    }

    /**
     * My set tester.
     */
    public void MySetTester(){
        MySet ms1 = new MySet();
        //add item
        System.out.println("Add three elements: 9, 2, 1.");
        ms1.addToSet(9);
        ms1.addToSet(2);
        ms1.addToSet(1);
        ms1.printSet(); //check items
        //add same item
        ms1.addToSet(2);
        ms1.addToSet(1);
        System.out.println("Add two same elements: 2, 1, check set size");
        System.out.println(ms1.getCardinality()); //check set size
        System.out.println("check 9 is in my set?");
        System.out.println(ms1.isInSet(9));
        ms1.clear();
        System.out.println("After clearing the set");
        ms1.printSet();



        MySet ms2 = new MySet();
        ms2.addToSet(1);
        ms2.addToSet(2);
        ms2.addToSet(3);

        MySet ms3 = new MySet();
        ms3.addToSet(7);
        ms3.addToSet(2);
        ms3.addToSet(5);

        System.out.println("the intersection of [1,2,3] and [2,5,7] is");
        MySet ms4 = ms2.intersection(ms3);
        ms4.printSet();
    }

    /**
     * Lottery tester.
     */
    public void LotteryTester(){
        Scanner sc = new Scanner(System.in);
        //test validation of name
//        ArrayList<Player> players = new ArrayList<>();
//        for (int i = 0; i < 5; i++) {
//            while(true) {
//                System.out.println("Enter player " + (i + 1) + "'s name:");
//                String name = sc.nextLine();
//                if (name == null){
//                    System.out.println("The player's name must not be empty.");
//                }else{
//                    Player player = new Player(name);
//                    players.add(player);
//                    break;
//                }
//            }
//        }
    }
}
